<?php
/**
 * Created by PhpStorm OF Administrator.
 * User: YUYI
 * Date: 2018/9/3 0003
 * Time: 上午 9:52
 * Administrator
 */

namespace app\swoole\service;


use app\common\model\Users;
use app\swoole\entity\SendMessage;

class IndexService
{
    /**
     * 发送信息对象
     * @var SendMessage 
     */
    protected static $instance;
    /**
     * 获取单例
     * @param  [swoole_websocket_server] $serv [websocket_server对象]
     * @param  [int] $from [谁发出的消息]
     * @param  [int] $type [0初始化  1登录通知  2离线通知  3普通消息]
     * @return [type]       [description]
     */
    public static function getInstance($serv = null,$from = null,$type = null){
        if (!$serv) {
            return isset(self::$instance)?self::$instance:false;
        }
        if (!isset(self::$instance)) {
            self::$instance = new SendMessage($serv,$from,$type);
        }
        return self::$instance;
    }
}